<?php
if (!defined("IN_OP_CEN"))
{
    exit("You can't access this file directly....");
}
require_once( "class_3d/CheckMode_3d.php" );
require_once( "class_5h/MyLotto_5h.php" );
$gametype = intval(getvar("gametype"));
$MyLotto_3d = new MyLotto_5h($gametype);
$g_betname_3or5 = judge_type($gametype, false);
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$show5N = getShow35($gametype);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
$bettype1_0_5hStr = "";
$_cen_flag = 1;
$cid = 0 - 1;
include_once( "centralize/centralize_class/config_cen.php" );
include_once( "centralize/centralize_class/db_cen.php" );
$cid = intval(getvar("cid"));
if (!isset($g_cen_info[$cid]))
{
    exit(" error cid ");
}
$now_list_chk = " ※ 指定操盘站别:";
$now_list = "";
$now_list .= " ※ 目前站别:<strong>" . $g_cen_info[$cid]['siteName'] . "</strong> || ";
$dbcen = new DB_CEN($cid);
foreach ($g_cen_info as $key => $val)
{
    $conStatFlag = $dbcen->chkCidConnect($key);
    if ($key == $cid)
    {
        $cls = "row2";
        if ($conStatFlag)
        {
            exit("error db connect - " . $cid);
        }
    }
    else
    {
        $cls = "row1";
    }
    $sName = $val['siteName'];
    if ($conStatFlag)
    {
        $now_list .= "※ <span class='red'>{$sName}(连线异常,请尽快通知系统管理者)</span>";
        $now_list_chk .= " <label>ｘ{$sName}</label>";
    }
    else
    {
        $now_list .= "※ <a href='op.php?op=centralize&fp=op_cen&cen=now_3d&gametype={$gametype}&cid={$key}' class='{$cls}'>{$sName}</a>";
        $now_list_chk .= " <label><input type='checkbox' name='cen_id[]' value='{$key}' />{$sName}</label>";
    }
}
$now_list .= " || " . $now_list_chk;
$now_list = "<div class='msgBox-yellow' style='width:990px;text-align:left;'>" . $now_list . "</div>";
$dbcen->chgCidConnect($cid);
if ($chkGametype == 3)
{
    require_once( "class_5h/RateConfig_5h.php" );
    require_once( "class_5h/SRate_5h.php" );
    $RateConfig_3d = new RateConfig_5h($gametype);
    $tempArray = array();
    $tempOrderArr = array("r1" => "r1", "r1clr" => "r1clr", "rnp" => "rnp", "rc" => "rc");
    $tempNoQuickArr = array();
    if ($gametype == 7)
    {
        $_5hFlag = true;
        $_8hFlag = false;
    }
    else
    {
        $_5hFlag = false;
        $_8hFlag = true;
    }
    $bettype1_0_5h = intval($conf->get("bettype1_0_{$tbl}"));
    if ($bettype1_0_5h)
    {
        $bettype1_0_5hStr = "<span class=\"msgBox-yellow\">双面盘操盘连动:<font color=red>开启</font></span>";
    }
    else
    {
        $bettype1_0_5hStr = "<span class=\"msgBox-yellow\">双面盘操盘连动:<font color=blue>关闭</font></span>";
    }
    $alertMsg = "※ 操盘页面之赔率异动，下限为0。\\n※ 双面盘操盘根据【增量】值作异动。\\n※ 双面盘操盘连动【开启】时，操盘时将连动定位之相对应之号码。\\n" . ( $_5hFlag ? "※ 更新【X盘】赔率时,【Y盘】连动；更新【Y盘】赔率时,【X盘】连动。\\n" : "" ) . "※ 操盘後将自动刷新页面。";
}
else
{
    require_once( "class_3d/RateConfig_3d.php" );
    require_once( "class_3d/SRate_3d.php" );
    $RateConfig_3d = new RateConfig_3d($gametype);
    $tempArray = array("r3" => "r3", "r3p" => "r3p", "rcmp" => "rcmp");
    $tempOrderArr = array("r1" => "r1", "r1p" => "r1p", "g3" => "g3", "g6" => "g6");
    $tempNoQuickArr = array("r2" => "r2", "r2p" => "r2p");
    $_5hFlag = false;
    $_8hFlag = false;
    $alertMsg = "※ 操盘页面之赔率异动，下限为0。\\n※ 双面盘操盘根据【增量】值作异动。\\n※【组选三】与【组选六】快选增量以【组选 - 5】的赔率作为各别组选的连动(以异动之百分比作运算)。\\n※ 操盘後将自动刷新页面。";
}
switch ($chkGametype)
{
    case 1 :
        $SRate_3d = new SRate_3d($gametype, $cid);
        break;
    case 2 :
        $SRate_3d = new SRate_3s($gametype, $cid);
        unset($RateConfig_3d->playtypeArr02['r1pass']);
        break;
    case 3 :
        $SRate_3d = new SRate_5h($gametype, $cid);
        break;
    default :
        exit("error chkGametype");
        break;
}
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$pg = $g_gametype_3d[$gametype]['pg'];
$split = 1;
$disk = 0;
$order = 0;
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
$ratemod = 0;
if ($id == "")
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_3d->getLotto3DByDate($showday);
}
else
{
    $id = intval($id);
    $lottoData = $SRate_3d->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ($lottoData == "")
{
    $ui->showErrorPage(( 0 - 1 < $cid ? $g_cen_info[$cid]['siteName'] . " --- " : "" ) . "目前没有{$tblName}可以下注期数！", true);
    exit();
}
$split = isset($RateConfig_3d->splitArr[$split]) ? $split : 0;
$playtype = isset($RateConfig_3d->playtypeArr02[$playtype]) ? $playtype : "r1";
if ($bid != "")
{
    $fieldsArr = array($bid);
}
else
{
    $fieldsArr = $RateConfig_3d->playGroupArr02[$playtype];
}
$bidstr = "";
if ($bid == "")
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if (!in_array($bid, $RateConfig_3d->playGroupArr02[$playtype]))
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=" . $bid;
    $tpl->set("bid", $bid);
}
$menu_list_url = "";
$tempArr = array();
if ($show5N)
{
    $jsFuname = "_n5";
    $jsFunameFlag = "true";
}
else
{
    $jsFuname = "";
    $jsFunameFlag = "false";
}
if ($_5hFlag)
{
    $xyid = 1;
    $tempArr[] = "<th width='10%'>" . getOptionXYList($xyid, true, "", "xyid", "xyid") . "<span id='noxystr' class='noneRateRecord'>单一盘</span></th>";
}
foreach ($RateConfig_3d->playtypeArr02 as $key => $val)
{
    if ($playtype == $key)
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' ><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("", $tempArr);
switch ($chkGametype)
{
    case 1 :
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ($stopbet_3d == "0000")
        {
            $stopbet_3d = "2359";
        }
        $tempStrInt = false;
        break;
    case 2 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
    case 3 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
    default :
        exit("error chkGametype - 2");
        break;
}
if ($tempStrInt == false)
{
    $h = substr($stopbet_3d, 0, 2);
    $m = substr($stopbet_3d, 2);
    $tempStr = "{$showday} {$h}:{$m}:00";
    $timetamp = systime();
    $timetamplimit = strtotime($tempStr) - $timetamp;
}
else
{
    $timetamp = systime();
    $timetamplimit = $tempStrInt - $timetamp;
}
$disabledbet = "";
if ($timetamplimit < 1)
{
    $disabledbet = "disabled=\"disabled\"";
}
$tpl->load("main", "now_3d.htm");
$quickBtnDisplay = "";
if (isset($tempOrderArr[$playtype]))
{
    $order = 2;
}
if (isset($tempArray[$playtype]))
{
    $quickBtnDisplay = "&nbsp;<input type=\"button\" id=\"btnQuickRate\" value=\"快速变更赔率\" />";
}
if (isset($tempNoQuickArr[$playtype]))
{
    $btnQuickStr = " [ <font style=\"color:blue;font-weight:bold;\">设定</font> -- <input type=\"button\" value=\"快速变更赔率\" id=\"btnRateQuickRecord\" /> ]&nbsp;&nbsp;&nbsp;";
}
else
{
    $btnQuickStr = "";
}
$tpl->set(array("playtype" => $RateConfig_3d->playtypeArr02[$playtype], "menu_list_url" => $menu_list_url, "lotto_id_3d" => $lottoData['id'], "round" => $lottoData['round'], "open" => $lottoData['open'], "timetamp" => $timetamp, "timetamplimit" => $timetamplimit, "playtypestr" => $playtype, "split" => $split, "order" => $order, "disk" => $disk, "ratemod" => $ratemod, "disabled" => $disabledbet, "quickBtnDisplay" => $quickBtnDisplay, "gametype" => $gametype, "gametypeStr" => $tblName, "btnQuickStr" => $btnQuickStr, "reloadCK" => "10", "jsLang" => $g_conf['language'], "jsFuname" => $jsFuname, "alertMsg" => $alertMsg, "pg" => $pg, "bettype1_0_5hStr" => $bettype1_0_5hStr));
$tpl->set(array("now_list" => $now_list, "siteName" => $g_cen_info[$cid]['siteName'], "input_cid" => "<input type=\"hidden\" name=\"cid\" value=\"" . $cid . "\" />"));
if ($conf->get("protect_start_{$tbl}") == "1")
{
    $btnSetConfFly = "true";
}
else
{
    $btnSetConfFly = "false";
}
$jslink = "<script src=\"js_3d/jquery-ui-1.8.11.custom.min.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script> ";
$jslink .= " var __roundID = " . $lottoData['id'] . "; ";
$jslink .= " var __reloadCK = 0; ";
$jslink .= " var now = new Date(1000 * {$timetamp}); ";
$jslink .= " var timestap = {$timetamplimit}; ";
$jslink .= " var myGlobalVal = {}; ";
$jslink .= " myGlobalVal.gametype = '{$gametype}'; ";
$jslink .= " myGlobalVal.lotto_id_3d = " . $lottoData['id'] . "; ";
$jslink .= " myGlobalVal.lotto_id = " . $lottoData['id'] . "; ";
$jslink .= " myGlobalVal.playtypestr = '{$playtype}'; ";
$jslink .= " myGlobalVal.open = '" . $lottoData['open'] . "'; ";
$jslink .= " myGlobalVal.reloadCK = '10'; ";
$jslink .= " myGlobalVal.jsFuname = {$jsFunameFlag}; ";
$jslink .= " myGlobalVal.btnSetConfFly = {$btnSetConfFly}; ";
$jslink .= " myGlobalVal.chkSynBall18 = false; ";
$jslink .= " myGlobalVal.top5 = ''; ";
$jslink .= " myGlobalVal.top10 = ''; ";
$jslink .= " myGlobalVal.top20 = ''; ";
$jslink .= " myGlobalVal.cidChk = true; ";
$jslink .= " var _playtype = 'r1'; ";
if ($_8hFlag || $_5hFlag)
{
    $jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别1</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别2</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别3</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
}
else
{
    $jslink .= "var _myHeader = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
}
$jslink .= "</script>";
$jslink .= "<script src=\"scr{$pg}/" . $g_conf['language'] . "/now" . ( $_8hFlag ? "8h" : "" ) . "_c.js\"></script>\n";
if (intval($conf->get("myCssChange_3d")))
{
    $jslink .= "<style>input.btnplus, input.btnmin{ \tcolor: #000000; \tbackground-color: #ffffff; \tborder: 1px solid #c8c8c8; \ttext-indent: 2px; \tcursor: pointer; \tbackground-image: url(core/tpl/k2/image/bgGray02.png); \tbackground-repeat: repeat-x; \tbackground-position: center; }</style>";
    $tpl->set("myCssChange_3dCHKSTR", "checked");
}
$ui->set("jslink", $jslink);
$number = intval(getvar("number"));
if ($number == "")
{
    $number = 1;
}
$OK = two_long($gametype, $flag = $number == 1 ? true : false, 3);
foreach ($OK as $key => $value)
{
    $sd = array(1 => "<font class=text01>单</font>", 2 => "<font class=text02>双</font>");
    $bs = array(1 => "<font class=text01>大</font>", 2 => "<font class=text02>小</font>");
    $color = array(1 => "<font color=\"red\">红</font>", 2 => "<font color=\"blue\">蓝</font>", 3 => "<font color=\"green\">绿</font>");
    $four = array(1 => "<font color=\"saddlebrown\">福</font>", 2 => "<font color=\"dimgray\">禄</font>", 3 => "<font color=\"darkorange\">寿</font>", 4 => "<font color=\"5200A0\">喜</font>");
    $position = array(1 => "<font color=\"saddlebrown\">东</font>", 2 => "<font color=\"dimgray\">南</font>", 3 => "<font color=\"darkorange\">西</font>", 4 => "<font color=\"5200A0\">北</font>");
    $three = array(1 => "<font color=\"red\">中</font>", 2 => "<font color=\"blue\">发</font>", 3 => "<font color=\"green\">白</font>");
    $animal = array(1 => "<font class=text01>龙</font>", 2 => "<font class=text02>虎</font>");
    $pc = array(1 => "<font class=text01>质</font>", 2 => "<font class=text02>合</font>");
    $key_change = substr($key, 0, 0 - 2);
    $last = $key[strlen($key) - 1];
    if ($gametype != 7 && $gametype != 8)
    {
        $bettype = array(1 => "单双", 2 => "大小", 3 => "质合");
        $median = array(1 => "个", 2 => "拾", 3 => "百", 4 => "千", 5 => "万");
        foreach ($bettype as $key2 => $value2)
        {
            foreach ($median as $key3 => $value3)
            {
                foreach ($g_betname_3or5 as $key4 => $value4)
                {
                    if (!( substr($key, 0, 0 - 4) == $key2 && $key[strlen($key) - 3] == $key3 ) || !( $value4 == $value3 . $value2 ))
                    {
                        $key_change = $key4;
                    }
                }
            }
        }
    }
    foreach ($g_betname_3or5 as $key1 => $value1)
    {
        if (!( $key_change == $key1 ))
        {
            continue;
        }
        else if ($gametype == 7 || $gametype == 8)
        {
            $type = array(1 => $sd, 2 => $bs, 3 => $bs, 4 => $sd, 5 => $gametype == 7 ? $color : $three, 6 => $gametype == 7 ? $four : $position, 7 => $sd, 8 => $bs, 9 => $bs, 18 => $animal);
            $show[$value1 . "&nbsp;-&nbsp;" . $type[substr($key, 0, 0 - 4)][$last]] = $value;
        }
        else
        {
            $type = array("单双" => $sd, "大小" => $bs, "质合" => $pc, "虎和" => $animal);
            $show[$value1 . "&nbsp;-&nbsp;" . $type[substr($value1, 0 - 4)][$last]] = $value;
        }
    }
}
$display = "<div>";
$display .= "<table class=\"tblMy3D\" style=\"width:100px;\">";
$display .= "<tr class=\"bgImg_{$gametype}\">";
$display .= "<td colspan=\"2\" align=\"center\">两面长龙排行</td></tr>";
$display .= "<tr class=\"bgImg_{$gametype}\" align=\"center\"><td colspan=\"2\" nowrap>";
$display .= "<label><input type=\"radio\" onclick=\"check_box(1)\"" . ( $flag ? "checked" : "" ) . ">出球</label>&nbsp;&nbsp;";
$display .= "<label><input type=\"radio\" onclick=\"check_box(2)\"" . ( $flag ? "" : "checked" ) . ">无出</label></td></tr>";
if (isset($show))
{
    arsort($show);
    foreach ($show as $key => $value)
    {
        $display .= "<tr class=\"left_td2\">";
        $display .= "<td nowrap style=\"font-weight:bold; color:black; text-align:right\">&nbsp;" . $key . "</td>";
        $display .= "<td nowrap>" . $value . "&nbsp;期&nbsp;</td></tr>";
    }
}
else
{
    $display .= "<tr class=\"left_td2\" align=\"center\">";
    $display .= "<td nowrap>无资料</td>";
    $display .= "<td nowrap>无资料</td></tr>";
}
$display .= "</table></div>";
$tpl->set("display", $display);
$ui->header();
$tpl->show("main");
$ui->footer();
?>